package aufagabe2.master;

import java.io.Serializable;
import java.math.BigInteger;

/*
 * This class allows to get the data from the GUI and to send them to the master
 */

public class GUIdata implements Serializable {
	
	private static final long serialVersionUID = 6465262985949828630L;
	private String address;
	private int port;
	private String typeOf;
	private BigInteger toFactorize;
	
	public GUIdata(){}
	
	/**
	 * @param address
	 * @param port
	 */
	public GUIdata(String address, int port){
		this.address = address;
		this.port = port;
	}
	
	/**
	 * @param o the object to compare with the current GUIdata
	 */
	@Override
	public boolean equals(Object o) 
	{		  
	    if (o instanceof GUIdata)
	    {
	      GUIdata data = (GUIdata) o;
	      if (this.address.equals(data.getAddress()) && this.port == data.getPort()) 
	    	  return true;
	    }
	    return false;	    
	}
	
	/**
	 * @return the address
	 */
	public String getAddress() {
		return address;
	}
	
	/**
	 * @param address the address to set
	 */
	public void setAddress(String address) {
		this.address = address;
	}
	
	/**
	 * @return the port
	 */
	public int getPort() {
		return port;
	}
	
	/**
	 * @param port the port to set
	 */
	public void setPort(int port) {
		this.port = port;
	}

	/**
	 * @return the toFactorize
	 */
	public BigInteger getToFactorize() {
		return toFactorize;
	}

	/**
	 * @param toFactorize the toFactorize to set
	 */
	public void setToFactorize(BigInteger toFactorize) {
		this.toFactorize = toFactorize;
	}
	
	/**
	 * @param toFactorize the toFactorize to set
	 */
	public void setToFactorize(String toFactorize) {
		this.toFactorize = new BigInteger(toFactorize);
	}

	/**
	 * @return the typeOf
	 */
	public String getTypeOf() {
		return typeOf;
	}

	/**
	 * @param typeOf the type of message : "addWorker", "delWorker" or "factorize"
	 */
	public void setTypeOf(String typeOf) {
		this.typeOf = typeOf;
	}

}
